<?php
        session_start();
        include "generador_tablas.php";
?>
<div class="col-lg-8">
    <div class="panel panel-default">
        <div class="panel-body" style = "background: #CEE3F6">
                        <div class="col-xs-12"><h2><b id="resaltador"> Centros de Investigación</b></h2><br/></div>
                        <div class = "col-xs-12"></br></div>
                        <form method="post" action ="eliminar_registro.php" class = "col-xs-12">
                                <div class="panel panel-default col-xs-12" style = "background: #EBF6FF">
                                        <?php 
                                                mostrar_tabla('centro_de_investigacion',array('id','nombre'),'id');
                                        ?>
                                </div></br>
                                <div class = "col-md-2"></div>
                                <div class = "col-md-4"><input type="button" class = "btn btn-primary col-xs-12" id ="modificar" value ="Modificar" disabled></div>
                                <div class = "col-md-4"><input class = "btn btn-primary col-xs-12" id="eliminar" type="submit" value = "Eliminar" disabled></div></br></br></br>
                                <div class = "col-md-2"></div>
                                <div class="row-fluid"></div><div class="row-fluid"></div>
                                <input type="hidden" name="tabla" value="centro_de_investigacion">
                                <input type="hidden" name="campo" value="id">
                                <input type="hidden" name="pagina" value="gestionar_centro">
                        </form>
                </div>
        </div>
</div>
<div class="col-lg-4">
    <div class="panel panel-default">
        <div id = "seleccionado" class="panel-body" style = "background: #CEE3F6">
    </div>
</div>

<script>
        $("#myTable").dataTable({
            "oLanguage": {
                "sUrl": "lang/dataTables.spanish.txt"
            }
        } );
</script>
<script>
    function carga(p1, p2, p3)
    {
            var xxx = {
                    dato: p1,
                    tabla: p2,
                    campo: p3
            };
        $.ajax({type:"POST",url:"mostrar_datos.php",data: xxx, success:function(result){$("#seleccionado").html(result);}});
    }
    $("#eliminar").click(function(){return confirm("¿Está seguro que desea eliminar este(os) registro(s)?")});

    $("#modificar").click(
            function ()
            {
                    var xxx = {
                            dato: $("#myTable input:checkbox:checked").val(),
                            tabla: 'centro_de_investigacion',
                            campo: 'id'
                    };
                $.ajax({type:"POST",url:"modificar_centro.php",data: xxx, success:function(result){$("#caja").html(result);}});
            }
    );

    $(".chkbox").change(function()
    {
        if ($("input:checkbox:checked").length>0)
        {
            if($("input:checkbox:checked").length>1)
                $("#modificar").attr("disabled", "disabled");
            else
                $("#modificar").removeAttr("disabled");

            $("#eliminar").removeAttr("disabled");
        }   
        else if($("input:checkbox:checked").length==0)
        {
            $("#eliminar").attr("disabled", "disabled");
            $("#modificar").attr("disabled", "disabled");
        }
    });

    <?php  if(isset($_SESSION['reescribir'])&&$_SESSION['reescribir']=="N"){?>
                $("#modificar").hide();
    <?php  }?>
    <?php  if(isset($_SESSION['borrar'])&&$_SESSION['borrar']=="N"){?>
                $("#eliminar").hide();
    <?php  }?>
</script>